<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Search extends CI_Controller
{
	private function list_any_users()
	{
		$rows = $this->data_source->get_any_users();
		$data['rows'] = $rows; 
		
		$this->load->view("search/searchResult", $data);
	}
	
	private function list_relevant_users($keyword)
	{
		$relevant_user = $this->data_source->get_relevant_user($keyword);
		
		$data = array(
				"relevant_user"=>$relevant_user,
				);
		
		$this->load->view("search/searchResult", $data);
	}

	
	public function __construct()
	{
		parent::__construct();
		$this->load->model("search_model","data_source");
		$this->load->model("personal_health_info_model");
		$this->load->model("customer_model");
	}
	
	public function do_search()
	{
		$keyword = $_REQUEST["searchKW"];
		if(empty($keyword))
		{
			$this->list_any_users();
		}
		else
		{
			$this->list_relevant_users($keyword);
		}
	}
	
	public function show_user_analyse($uid)
	{
		$data = array();
		$data['title'] = '健康信息查看';
		$data['lastLoginTime'] = $this->customer_model->get_last_login($uid);
		$data['totalScore'] = '80';
		$data['symptoms'] = $this->personal_health_info_model->get_symptoms($uid);
		$data['nick_name'] = get_user_nick_name($uid);
		
		$this->load->view("search/viewUserAnalyse", $data);
	}
}
?>